home *** CD-ROM | disk | FTP | other *** search
- // VIRTUAL.L - Demonstrate all member functions are virtual.
-
- class base
- {
- print() { w << "Base class\n"; }
- print2() { print(); }
- baseprint() { base::print(); }
- };
-
- class derived : base
- {
- print() { w << "Derived class\n"; }
- };
-
- main() {
- w = new textwindow ("base vs. derived");
- w.show();
- base b = new base;
- derived d = new derived;
- w << "b.print():";
- b.print();
- w << "b.print2():";
- b.print2();
- w << "b.baseprint():";
- b.baseprint();
- w << "d.print():";
- d.print();
- w << "d.print2():";
- d.print2();
- w << "d.baseprint():";
- d.baseprint();
- }
-
-